#include "l5image.h"

L5Image::L5Image() : SatellitalImage()
{
}

bool L5Image::readImage(QVector<QString> headers)
{
    QFile file(headers.at(0));
    QString data;
    if (!file.open(QIODevice::ReadWrite))
        return false;
    else
    {
        QTextStream in(&file);
        while (!in.atEnd())
        {
            data += in.readLine();
        }
    }
    file.close();
    
    QFileInfo inf(file);
    this->bandsPaths << inf.absolutePath() + "/BAND1.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND2.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND3.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND4.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND5.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND6.dat";
    this->bandsPaths << inf.absolutePath() + "/BAND7.dat";

    int index = 0;
    QVariant value;

    // busco el ancho de la imagen
    index = data.indexOf("PIXELS PER LINE");
    value = this->getNumericValueOf(index + 17, data);
    this->width = value.toInt();

    // busco el alto de la imagen
    index = data.indexOf("LINES PER IMAGE");
    value = this->getNumericValueOf(index + 17, data);
    this->height = value.toInt();

    return true;
}
